package com.ljh.account.mapper;



import com.ljh.account.dao.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Insert("INSERT INTO categories (category_name, description) VALUES (#{categoryName}, #{description})")
    void insertCategory(Category category);

    @Select("SELECT * FROM categories WHERE id = #{id}")
    Category findById(Integer id);

    @Select("SELECT * FROM categories")
    List<Category> findAll();

    @Update("UPDATE categories SET category_name = #{categoryName},  description = #{description}, updated_at = CURRENT_TIMESTAMP WHERE id = #{id}")
    void updateCategory(Category category);

    @Delete("DELETE FROM categories WHERE id = #{id}")
    void deleteById(Integer id);

}
